#ifndef ARTISTIC_H
#define ARTISTIC_H

#include <QGLWidget>
#include "common.h"
#include <string>
#include <QGLFramebufferObject>
#include <stdio.h>
#include <list>
#include "treedraw.h"
#include <QHash>
#include "treegen.h"
#include "scene2d.h"
class QFile;
class Scene2D;
#define CANVAS_SIZE 2000
// WIDTH2D defines the width of the 2d canvas.
// As I cannot use artistic->width() to get the actual width, I define it to be 762,
// The width is actually 762 though.
#define WIDTH2D 762


//Artistic Rendering Class
class Artistic : public QGLWidget {
    Q_OBJECT
signals:
     void _mouseDrag(QMouseEvent *);
public:
    Artistic(QWidget *parent = 0);
    ~Artistic();
       QHash<QString, GLuint> framebuffer_objects;
    bool modeInteract;
    float lambda;
    float tropism;
    float aux_angle;
    float shed_thres;
    float term_weight;
    float aux_weight;
    float diameter_rate;
    float tlength;
    float alength;
    float alpha;
    void applyValues();
    void clearTree();
    void iterateTree();
    Scene2D *scene;
    bool shadow_mode;

    bool saveScene(QString filename);
    bool loadScene(QString filename);


protected:
     //Inherited Methods
     void initializeGL();
     void paintGL();
    // Interaction events
     void resizeGL(int w, int h);
     void mousePressEvent(QMouseEvent *event);
     void mouseMoveEvent(QMouseEvent *event);
     void wheelEvent(QWheelEvent *event);
     void updateCamera();
     void keyPressEvent(QKeyEvent *event);
     void keyReleaseEvent(QKeyEvent *event){}
     //Texturing methods
          void load_framebuffers(int w, int h);
      GLuint loadTexture(const QString &filename);




  private:
     QTimer *mTimer;
     float mFPS, mIncrement;
     Camera *mCamera;
     GLUquadric *mQuadric;
     float2 mLastMousePos;
     float screenScale;
     float2 screenCenter;

//     TreeDraw *drawer;
//     TreeGen2D *tree0;
protected slots:
     void mouseDragEvent(QMouseEvent *event);
     void redraw();


};
#endif // ARTISTIC_H
